include $(TOPDIR)/rules.mk

PKG_NAME:=ccnu
PKG_VERSION:=2.0
PKG_RELEASE:=1

PKG_BUILD_DIR:=$(BUILD_DIR)/ccnu-$(PKG_VERSION)
PKG_MAINTAINER:=南浦月 <nanpuyue@gmail.com>

include $(INCLUDE_DIR)/package.mk

define Package/ccnu
  CATEGORY:=Network
  SUBMENU:=802.1x
  DEPENDS:=+libc +libgcc
  TITLE:=iNode Compatible Client for CCNU
endef

define Package/ccnu/description
        iNode Compatible Client for CCNU
endef

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Package/ccnu/install
	$(INSTALL_DIR) $(1)/usr/sbin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/ccnu $(1)/usr/sbin
endef

define Package/luci-app-ccnu
  CATEGORY:=LuCI
  SUBMENU:=3. Applications
  DEPENDS:=+libc +libgcc +ccnu
  TITLE:=iNode Compatible Client for CCNU
endef

define Package/luci-app-ccnu/description
        iNode Compatible Client for CCNU
endef

define Package/luci-app-ccnu/conffiles
/etc/config/ccnu
endef

define Package/luci-app-ccnu/install
	$(INSTALL_DIR) $(1)/usr/lib/lua/luci
	$(CP) ./files/luasrc/* $(1)/usr/lib/lua/luci
	$(INSTALL_DIR) $(1)/etc/config
	$(INSTALL_DATA) ./files/etc/config/ccnu $(1)/etc/config
	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_BIN) ./files/etc/init.d/ccnu $(1)/etc/init.d
endef

$(eval $(call BuildPackage,ccnu))
$(eval $(call BuildPackage,luci-app-ccnu))
